// HallFrame.cpp : implementation of the CHallFrame class
//
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "resource.h"

#include "aboutdlg.h"
#include "HallFrame.h"

BOOL CHallFrame::PreTranslateMessage(MSG* pMsg)
{
	return CFrameWindowImpl<CHallFrame>::PreTranslateMessage(pMsg);
}

bool CHallFrame::AppHibernate(bool bHibernate)
{
	// Insert your code here or delete member if not relevant
	return bHibernate;
}

bool CHallFrame::AppNewInstance(LPCTSTR /*lpstrCmdLine*/)
{
	// Insert your code here or delete member if not relevant
	return false;
}

void CHallFrame::AppSave()
{
	CAppInfo info;
	info.Save(m_bFullScreen, L"Full");
	// Insert your code here
}

#ifdef WIN32_PLATFORM_WFSP
void CHallFrame::AppBackKey()
{
	::SHNavigateBack();
}
#endif

BOOL CHallFrame::OnIdle()
{
	UIUpdateToolBar();
	return FALSE;
}

LRESULT CHallFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	CAppInfo info;

	// Full screen mode delayed restoration
	bool bFull = false;
	info.Restore(bFull, L"Full");

	if (bFull)
	{
		PostMessage(WM_COMMAND, ID_VIEW_FULLSCREEN);
	}

	CreateSimpleCEMenuBar();
#ifdef WIN32_PLATFORM_WFSP // SmartPhone
	AtlActivateBackKey(m_hWndCECommandBar);
#endif
	UIAddToolBar(m_hWndCECommandBar);

	// register object for message filtering and idle updates
	CMessageLoop* pLoop = _Module.GetMessageLoop();
	ATLASSERT(pLoop != NULL);
	pLoop->AddMessageFilter(this);
	pLoop->AddIdleHandler(this);

	return 0;
}

LRESULT CHallFrame::OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	PostMessage(WM_CLOSE);
	return 0;
}

LRESULT CHallFrame::OnAction(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	// TODO: add code

	return 0;
}

LRESULT CHallFrame::OnFullScreen(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	SetFullScreen(!m_bFullScreen);
	UISetCheck(ID_VIEW_FULLSCREEN, m_bFullScreen);

	return TRUE;
}

LRESULT CHallFrame::OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	CAboutDlg dlg;
	FSDoModal(dlg);
	return 0;
}
